package game.adm.controller;
import java.util.List;

import game.adm.dao.dto.BetDTO;
import game.adm.dao.dto.BonusDTO;
import game.adm.entity.BetEntityManager;
import game.adm.entity.BonusEntityManager;
import game.adm.struts.form.BetForm;
import game.web.base.Constants;
import projectx.core.base.ProjectXSystemException;
import projectx.core.base.ProjectXUserException;
import projectx.transaction.TransactionHandler;
import projectx.web.base.ProjectXDbTrxController;
import projectx.web.base.ProjectXForm;
import projectx.web.base.UserContext;

public class BetController extends ProjectXDbTrxController {

	protected BetController(UserContext uc, ProjectXForm form) {
		super(uc, form);
	}

	public Object execute() throws ProjectXUserException,
			ProjectXSystemException {
		debugBegin();

		UserContext uc = getUc();
		BetForm form = (BetForm)getForm();
		String operator = form.getOperator();
		
		if("1".equals(operator)){    //查询所有的下注记录
			List<BetDTO> betList = BetEntityManager.list(form);
			uc.put(Constants.ADM_BET_LIST, betList);
		}else if("2".equals(operator)){     //查询某下注记录详细信息
			BetDTO dto = BetEntityManager.getBetByID(form.getBetID());
			uc.put(Constants.ADM_BET_RECORD, dto);
		}

		debugEnd();
		return null;
	}

	public static Object execute(UserContext uc, ProjectXForm form)
			throws ProjectXUserException, ProjectXSystemException {
		return TransactionHandler.call(new BetController(uc, form));
	}
}
